home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr10 / tseacc13.zip / TSEACC13.S < prev    next >
Text File  |  1993-06-21  |  6KB  |  171 lines

  1. /**************** Foreign-Character Macros **************************
  2.  
  3.   For TSE (The Semware Editor), pre-release version 1.0
  4.  
  5.   Author:  David Mayerovitch
  6.            macro version 1.0 07 June 1993
  7.            macro version 1.1 12 June 1993
  8.            - added Spanish, more French characters
  9.            - removed International
  10.            macro version 1.2 15 June 1993
  11.            - added Spanish ordinals
  12.            macro version 1.3 20 June 1993
  13.            - macro source code uses Chr() notation rather than
  14.              character literals to preserve valid code if this
  15.              text should somehow pass through a high-ASCII filter
  16.            - minor documentation errors fixed
  17.  
  18.   The documentation portion of this text contains high-ASCII
  19.   characters which will not appear correctly if the file reaches you
  20.   after somehow passing through a high-ASCII filter.  However, in the
  21.   actual source code below, the Chr() notation ensures correct
  22.   compilation and functioning of the macro.
  23.   -------------------
  24.  
  25.   This pair of macros provides a quick and convenient way of entering
  26.   foreign-language and other special characters.
  27.  
  28.   mSelectLanguage() presents a menu of languages or other
  29.   special-character sets for the user to choose from. I have assigned
  30.   this macro to <Alt `>.
  31.  
  32.   mAccenter() enables the entry of the special characters belonging to
  33.   the selected set.  I have assigned this macro to the key <`>. Call
  34.   this the trigger key.
  35.  
  36.   These macros do what you do when writing foreign characters by hand:
  37.   first write the basic letterform, then add the diacritical mark.
  38.   Example: If the selected language is French and you want to enter
  39.   the character <é> (e with accent aigu): type the basic character <e>,
  40.   then press the trigger key.  A pop-up menu appears:
  41.  
  42.   ┌──────────┐
  43.   │ Aigu   é │
  44.   │ Grave  è │
  45.   │ Circ   ê │
  46.   │ Umlaut ë │
  47.   └──────────┘
  48.  
  49.   The hotkeys A, G, C, and U generate the four possible e-based
  50.   accented characters in French. Press <A> and the <e> just
  51.   typed will be replaced with <é>.
  52.  
  53.   When there is only one possible accented version of the character
  54.   just typed (e.g. ü in German), the macro automatically inserts it
  55.   without popping up a menu.
  56.  
  57.   The macros as presented here offer the following character sets:
  58.   French: à â ç Ç é è ê ë É î ï ô ù û
  59.   German: ä Ä ö Ö ü Ü
  60.   Spanish: á ª é í ó º ú ñ Ñ ¿ ¡
  61.   Currency: c/C --> ¢ (cents)  l/L --> £ (pounds)  y/Y --> ¥ (yen)
  62.  
  63.   French is the default: it is automatically selected when the macro
  64.   is loaded.  Change the default by changing the global variable
  65.   Language (see macro source below).
  66.  
  67.   You may easily edit the macros to provide any substitutions you
  68.   want.  Strings as well as single characters may be substituted: the
  69.   string "integer" could be expanded from "i", or your name from your
  70.   initial.  Modify the language menu to provide character sets of your
  71.   choice - math, Greek, graphics, and so on.
  72.  
  73.   If you have occasional need for characters from different languages,
  74.   you might group them into a single International set rather than
  75.   switching languages.  The tradeoff would be that you'd have fewer
  76.   automatic substitutions and more menu choices.
  77.  
  78.   If a printable key such as <`> is chosen as the trigger for
  79.   mAccenter(), the Literal() command (assigned to <Ctrl P> in the
  80.   factory configuration of TSE) may be used whenever the character
  81.   itself is required in the text.
  82.  
  83.   Comments and improvements are welcome.
  84.  
  85. ********************************************************************/
  86. // MACRO SOURCE CODE
  87.  
  88. integer language = 1 // French is default (make it 3 for Spanish)
  89.  
  90. // LANGUAGE SELECTION ROUTINES:
  91. menu langMenu() history
  92.   '&French'  '&German'   '&Spanish' '', , Divide  '&Currency'
  93. end
  94. proc mSelectLanguage()
  95.   langMenu()  language = MenuOption()
  96. end
  97.  
  98. // CHARACTER SUBSTITUTION ROUTINES:
  99. proc sub(string newstring)
  100. // replaces current char by newstring, forcing insert.
  101.   DelChar()  InsertText(newstring,_insert_)
  102. end
  103.  
  104. menu FrenchAMenu()
  105.   '&Grave '+Chr(133), sub(Chr(133))
  106.   '&Circ  '+Chr(131), sub(Chr(131)) end
  107. menu FrenchEMenu()
  108.   '&Aigu   '+Chr(130), sub(Chr(130))
  109.   '&Grave  '+Chr(138), sub(Chr(138))
  110.   '&Circ   '+Chr(136), sub(Chr(136))
  111.   '&Umlaut '+Chr(137), sub(Chr(137)) end
  112. menu FrenchIMenu()
  113.   '&Circ   '+Chr(140), sub(Chr(140))
  114.   '&Umlaut '+Chr(139), sub(Chr(139)) end
  115. menu FrenchUMenu()
  116.   '&Grave  '+Chr(151), sub(Chr(151))
  117.   '&Circ   '+Chr(150), sub(Chr(150)) end
  118. menu SpanishOMenu()
  119.   '&Accent  '+Chr(162), sub(Chr(162))
  120.   '&Ordinal '+Chr(167), sub(Chr(167)) end
  121. menu SpanishAMenu()
  122.   '&Accent  '+Chr(160), sub(Chr(160))
  123.   '&Ordinal '+Chr(166), sub(Chr(166)) end
  124.  
  125. proc French()
  126.   case Chr(CurrChar())
  127.     when 'a' FrenchAMenu() when 'e' FrenchEMenu()
  128.     when 'i' FrenchIMenu() when 'u' FrenchUMenu()
  129.     when 'E' sub(Chr(144)) when 'c' sub(Chr(135))
  130.     when 'C' sub(Chr(128))
  131.     when 'i' sub(Chr(140)) when 'o' sub(Chr(147))
  132.     otherwise Right() endcase
  133. end
  134. proc German()
  135.   case Chr(CurrChar())
  136.     when 'a' sub(Chr(132)) when 'A' sub(Chr(142))
  137.     when 'o' sub(Chr(148)) when 'O' sub(Chr(153))
  138.     when 'u' sub(Chr(129)) when 'U' sub(Chr(154))
  139.     otherwise Right() endcase
  140. end
  141. proc Spanish()
  142.   case Chr(CurrChar())
  143.     when 'a' SpanishAMenu() when 'o' SpanishOMenu()
  144.     when 'e' sub(Chr(130)) when 'i' sub(Chr(161))
  145.     when 'u' sub(Chr(163)) when 'n' sub(Chr(164))
  146.     when 'N' sub(Chr(165))
  147.     when '?' sub(Chr(168)) when '/' sub(Chr(168))
  148.                           // unshifted ? key
  149.     when '!' sub(Chr(173)) when '1' sub(Chr(173))
  150.                           // unshifted ! key
  151.     otherwise Right() endcase
  152. end
  153. proc Currency()
  154.   case UpCase(Chr(CurrChar()))
  155.     when 'C' sub(Chr(155)) // cents
  156.     when 'L' sub(Chr(156)) // pounds
  157.     when 'Y' sub(Chr(157)) // yen
  158.     otherwise Right() endcase
  159. end
  160.  
  161. proc mAccenter()
  162.   Left()
  163.   Case language
  164.     when 1 French() when 2 German() when 3 Spanish()
  165.     when 5 Currency()
  166.     endcase
  167. end
  168. <`> mAccenter()
  169. <Alt `> mSelectLanguage()
  170. /************************** End of macros **************************/
  171.